package com.zone.service.controller;

import java.util.List;
import java.io.IOException;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zone.common.log.annotation.Log;
import com.zone.common.log.enums.BusinessType;
import com.zone.common.security.annotation.RequiresPermissions;
import com.zone.service.domain.AtmFixGroup;
import com.zone.service.service.IAtmFixGroupService;
import com.zone.common.core.web.controller.BaseController;
import com.zone.common.core.web.domain.AjaxResult;
import com.zone.common.core.utils.poi.ExcelUtil;
import com.zone.common.core.web.page.TableDataInfo;

/**
 * atm固定车组Controller
 * 
 * @author zone
 * @date 2025-11-15
 */
@RestController
@RequestMapping("/atmFixGroup")
public class AtmFixGroupController extends BaseController
{
    @Autowired
    private IAtmFixGroupService atmFixGroupService;

    /**
     * 查询atm固定车组列表
     */
    @RequiresPermissions("service:atmFixGroup:list")
    @GetMapping("/list")
    public TableDataInfo list(AtmFixGroup atmFixGroup)
    {
        startPage();
        List<AtmFixGroup> list = atmFixGroupService.selectAtmFixGroupList(atmFixGroup);
        return getDataTable(list);
    }

    /**
     * 导出atm固定车组列表
     */
    @RequiresPermissions("service:atmFixGroup:export")
    @Log(title = "atm固定车组", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AtmFixGroup atmFixGroup)
    {
        List<AtmFixGroup> list = atmFixGroupService.selectAtmFixGroupList(atmFixGroup);
        ExcelUtil<AtmFixGroup> util = new ExcelUtil<AtmFixGroup>(AtmFixGroup.class);
        util.exportExcel(response, list, "atm固定车组数据");
    }

    /**
     * 获取atm固定车组详细信息
     */
    @RequiresPermissions("service:atmFixGroup:query")
    @GetMapping(value = "/{groupId}")
    public AjaxResult getInfo(@PathVariable("groupId") Long groupId)
    {
        return success(atmFixGroupService.selectAtmFixGroupByGroupId(groupId));
    }

    /**
     * 新增atm固定车组
     */
    @RequiresPermissions("service:atmFixGroup:add")
    @Log(title = "atm固定车组", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AtmFixGroup atmFixGroup)
    {
        return toAjax(atmFixGroupService.insertAtmFixGroup(atmFixGroup));
    }

    /**
     * 修改atm固定车组
     */
    @RequiresPermissions("service:atmFixGroup:edit")
    @Log(title = "atm固定车组", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AtmFixGroup atmFixGroup)
    {
        return toAjax(atmFixGroupService.updateAtmFixGroup(atmFixGroup));
    }

    /**
     * 删除atm固定车组
     */
    @RequiresPermissions("service:atmFixGroup:remove")
    @Log(title = "atm固定车组", businessType = BusinessType.DELETE)
	@DeleteMapping("/{groupIds}")
    public AjaxResult remove(@PathVariable Long[] groupIds)
    {
        return toAjax(atmFixGroupService.deleteAtmFixGroupByGroupIds(groupIds));
    }
}
